package jdbc;

import java.sql.*;

public class JdbcTwo {
    public static void  mian(String args[]) throws ClassNotFoundException, SQLException {
        String conn = "jdbc:mysql://localhost:3306/lxf?serverTimezone=GMT%2B8";
        String name = "root";
        String password = "root";
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(conn,name,password);
        System.err.println("链接数据库");
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from user");
        while (resultSet.next()){
            System.err.println(resultSet.getString("name"));
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
